﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Skyhook.Sprites
{
    internal static class SpriteLayersLayoutManager
    {
        static SortedDictionary<string, SpriteLayersLayout> LayoutsCache = null;

        static SpriteLayersLayoutManager()
        {
            LayoutsCache = new SortedDictionary<string, SpriteLayersLayout>();
        }

        private static SpriteLayersLayout AddLayoutToCache(string layoutname)
        {
            SpriteLayersLayout layout = new SpriteLayersLayout(layoutname);
            LayoutsCache.Add(layoutname, layout);
            return layout;
        }

        public static SpriteLayersLayout CreateLayout(string layoutname)
        {
            SpriteLayersLayout result = null;
            if( LayoutsCache.TryGetValue(layoutname,out result) )
            {
                return result;
            }

            result = AddLayoutToCache(layoutname);
            return result;
        }
    }
}
